home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#07 (Mar 86)
/
Pascal 2-3
/
Small Flight Source
/
flipPix.asm
< prev
next >
Wrap
Assembly Source File
|
1986-02-13
|
3KB
|
75 lines
;
; flippix -- complement a pixel on the screen, given its global coordinates.
; procedure flipPix (h, v: integer); external;
;
; Written by Mike Morton for MacTutor
; Converted to MDS Assembly by David E. Smith
;
;
xdef flipPix
include QuickEqu.D
include SysEqu.D
include ToolEqu.D
include MacTraps.D
MACRO .equ =equ| ; convert lisa stuff to mds
MACRO _hideCurs = _HideCursor|
MACRO _showCurs = _ShowCursor|
CrsrRect equ $83C ;SysEqu stuff
grafGlob equ $0
; parameter offsets from the stack pointer:
bitH .equ 4 ; horizontal pixel coordinate
bitV .equ bitH+2 ; vertical pixel coordinate
plast .equ bitV+2 ; address just past last parameter
psize .equ plast-bitH ; size of parameters, in bytes
; entrance: set up a stack frame, save some registers, hide cursor if needed.
flipPix:
clr.w D2 ; clear flag saying cursor was hidden
movem.w bitH(A7),D0/D1 ; load v. and h. coordinates together
; see if we'll need to hide the cursor while we draw
lea CrsrRect+top,A0 ; point to rectangle the cursor covers
cmp.w (A0)+,D0 ; compare v to rect.top
blt.s nohide ; if too small (above r.top), don't hide
cmp.w (A0)+,D1 ; compare h to rect.left
blt.s nohide ; if too small (left of r.left), don't hide
cmp.w (A0)+,D0 ; compare v to rect.bottom
bge.s nohide ; if too large (below r.bottom), don't hide
cmp.w (A0)+,D1 ; compare h to rect.right
bge.s nohide ; if too large (right of r.right, don't hide
_hideCurs ; must briefly hide the cursor to draw here
move.w #1,D2 ; flag that we did so
nohide swap D2 ; hidden or not: slide flag up to top of D2
move.l grafGlob(A5),A0 ; point to quickdraw globals
move.l thePort(A0),A0 ; point to the current grafport
mulu portBits+rowBytes(A0),D0 ; v. times stride is byte offset of row
move.b D1,D2 ; copy h. coord (low 3 bits) for bit offset
lsr.w #3,D1 ; extract byte offset
add.w D1,D0 ; combine v. and byte component of h.
not.b D2 ; make the bit# 68000-style (x := 7-x)
move.l portBits+baseAddr(A0),A0 ; pick up base address of bitmap
bchg D2,0(A0,D0.w) ; flip the bit in the right byte
swap D2 ; bring back cursor-hidden flag
tst.w D2 ; is it set?
beq.s return ; no -- all done
_showCurs ; yes -- show the cursor
return
move.l (A7)+,A0 ; pop return address
add.l #psize,A7 ; unstack parameters
jmp (A0) ; home to mother
.end ; of procedure flipPix